<?php
class demo {
	public function getUserInfo($p) {
		return "userInfo[$p]";
	}
	public function dealUserInfo($p) {
		return $p."-dealUserInfo";
	}
	public function getTopFeed($p) {
		return "topFeed[$p]";
	}
	public function dealTopFeed($p) {
		return $p."-dealTopFeed";
	}
}

class db {
	var $sql = "";

	public function query($sql) {
		$this->sql = $sql;
	}

	public function reap_async_query() {
		return $this->sql;
	}
}

function dealCommon($p) {
	return $p."-dealCommon";
}

$demo = new demo();

function get_info_from_db ($id) {
	$road = new road();
	$db = new db();
	$db->query("$id");
	$road->set(array($db, "reap_async_query"));
	return $road;
}

function user_model ($id) {
	$user_info = get_info_from_db($id);
	return $user_info;
}
function get_user($id) {
	global $demo;
	$road = user_model($id);
	$road->deal(array($demo, "dealUserInfo"));
	return $road;
}
function feed_model ($id) {
	$feed_info = get_info_from_db($id);
	return $feed_info;
}
function get_feed($id) {
	$road = feed_model($id);
	$road->deal("dealCommon");
	return $road;
}
//先把获取用户信息的请求发出去
$user_road = get_user(100);
//不需要等待用户信息返回，接着发送获取feed请求
$feed_road = get_feed(2);
//所有请求都已经发送完毕
//两个请求并行执行，从而节省整体时间。
//下面开始逐个获取数据
$result = $user_road->get();
$result2 = $feed_road->get();

var_dump($result);
var_dump($result2);